Finding Optimal Solution